package com.inspur.cmp;

import java.util.Map;
import org.jboss.logging.Logger;

public class EmailServiceFactory {

	private static final Logger LOG = Logger.getLogger(
            EmailServiceFactory.class);

	public static EmailService get(Map<String, String> config) {

		// 根据配置控制发送逻辑, 这里的simulation作为在认证流配置中的一个配置项

		if (Boolean.parseBoolean(config.getOrDefault("simulation", "false"))) {
			return (message, subject, context) ->
				LOG.warn(String.format("***** SIMULATION MODE ***** Would send Email to %s with text: %s", null, message));
		} else {
			// 这里只是模拟邮件发送, 真实环境需求实现邮件发送功能
//			return new InspurEmailService(config);
			return (message, subject, context) ->
					LOG.warn(String.format("***** another SIMULATION MODE ***** Would send Email to %s with text: %s", null, message));
		}
	}

}
